package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.GrowthMonit;
import com.ruoyi.system.service.IGrowthMonitService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * GrowthMonitController
 */
@Anonymous
@RestController
@RequestMapping("/system/monit")
public class GrowthMonitController extends BaseController
{
    @Autowired
    private IGrowthMonitService growthMonitService;

    /**
     * 查询鱼类成长监测列表
     */
    //@PreAuthorize("@ss.hasPermi('system:monit:list')")
    @GetMapping("/list")
    public TableDataInfo list(GrowthMonit growthMonit)
    {
        startPage();
        List<GrowthMonit> list = growthMonitService.selectGrowthMonitList(growthMonit);
        return getDataTable(list);
    }

    /**
     * 导出鱼类成长监测列表
     */
    //@PreAuthorize("@ss.hasPermi('system:monit:export')")
    @Log(title = "鱼类成长监测", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GrowthMonit growthMonit)
    {
        List<GrowthMonit> list = growthMonitService.selectGrowthMonitList(growthMonit);
        ExcelUtil<GrowthMonit> util = new ExcelUtil<GrowthMonit>(GrowthMonit.class);
        util.exportExcel(response, list, "鱼类成长监测数据");
    }

    /**
     * 获取鱼类成长监测详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:monit:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(growthMonitService.selectGrowthMonitById(id));
    }

    /**
     * 新增鱼类成长监测
     */
    @PreAuthorize("@ss.hasPermi('system:monit:add')")
    @Log(title = "鱼类成长监测", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GrowthMonit growthMonit)
    {
        return toAjax(growthMonitService.insertGrowthMonit(growthMonit));
    }

    /**
     * 修改鱼类成长监测
     */
    //@PreAuthorize("@ss.hasPermi('system:monit:edit')")
    @Log(title = "鱼类成长监测", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GrowthMonit growthMonit)
    {
        return toAjax(growthMonitService.updateGrowthMonit(growthMonit));
    }

    /**
     * 删除鱼类成长监测
     */
    //@PreAuthorize("@ss.hasPermi('system:monit:remove')")
    @Log(title = "鱼类成长监测", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(growthMonitService.deleteGrowthMonitByIds(ids));
    }
}
